package com.rent.search.aop;


import com.log.event.SysLogListener;
import com.rent.search.service.ISysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author zhang
 * @create 2022/3/31 14:13
 */
@Slf4j
@Configuration
public class LogAspectConfig {

    @Autowired
    private ISysLogService systemLogService;

    /**
     * zn.log.enabled = true 并且 mb.log.type=DB时实例该类
     */
    @Bean
    @ConditionalOnExpression("${zn.log.enabled:true} && 'DB'.equals('${zn.log.type:DB}')")
    public SysLogListener sysLogListener() {
//        ISysLogService logService = systemLogService;
        return new SysLogListener(systemLogService::insertLog);
    }

}
